{include file="public/head" /}
<style>input[name='keyword']{width: 210px}</style>
</head>
<body>
{include file="public/top" /}
<div class="am-cf admin-main">
    {include file="public/nav" /}

    <!-- content start -->
    <div class="admin-content">
        <div class="admin-content-body">
            <div class="am-cf am-padding">
                <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">用户信息管理</strong> / <small>学生用户列表</small></div>

            </div>

            <div class="am-u-md-12">
                <div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">
                        <a href="/admin/User/add" class="am-btn am-btn-primary">添加</a>
                    </div>
                    <div class="am-u-sm-12 am-u-md-6">
                        <form method="post" action="/admin/User/index">
                            <div class="am-form-group">
                                <input type="text" name="keyword" value="{:input('request.keyword')}" placeholder="按学号,姓名,用户名,手机号">
                                <button type="submit" class="am-btn am-btn-secondary am-btn-xs">搜索</button>
                                <a href="/admin/User/index" class="am-btn am-btn-danger am-btn-xs">重置</a>
                            </div>
                        </form>
                    </div>
                </div>

                <table class="am-table am-table-bordered am-table-radius am-table-striped">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>用户名</th>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>手机</th>
                        <th>邮箱</th>
                        <th>身份证号</th>
                        <th>出生日期</th>
                        <th>照片</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {php}
                    $Sex = ['男','女','未设置'];
                    {/php}
                    {volist name="rows" id="vo"}
                    <tr>
                        <td>{$vo.id}</td>
                        <td>{$vo.username}</td>
                        <td>{$vo.name}</td>
                        <td>{$Sex[$vo.sex]}</td>
                        <td>{$vo.mobile|default='无'}</td>
                        <td>{$vo.email|default='无'}</td>
                        <td>{$vo.id_card}</td>
                        <td>{$vo.birthday}</td>
                        <td>
                            <a href="javascript:;" onclick="showPhoto('{$vo.photo}')">
                                <img src="{$vo.photo}" width="30" height="30" title="点击查看大图">
                            </a>
                        </td>
                        <td>
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-xs">
                                    <a href="{:url('admin/user/edit',['id'=>$vo['id']])}" class="am-btn am-btn-success" style="color: #fff;">编辑</a>
                                    <button type="button" class="am-btn am-btn-danger" onclick="del(this,{$vo.id})">删除</button>
                                </div>
                            </div>
                        </td>
                    </tr>
                    {/volist}
                    </tbody>
                </table>
                <span>共{$rows->total()}条记录</span>
                <div class="pagination" style="float: right">{$page}</div>
            </div>
        </div>
    </div>
</div>
<!-- content end -->
</div>
<a href="#" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu" data-am-offcanvas="{target: '#admin-offcanvas'}"></a>
<script src="__STATIC__/js/ajax_form.js"></script>
<script>
    function del(self,id) {
        layer.confirm('确认要删除吗?', function (index) {
            $.post("{:url('admin/User/delete')}", {id: id}, function (res) {
                if (res.code == 1) {
                    $(self).closest("tr").remove();//前端删除
                    layer.msg(res.msg, {time: 1500, icon: 6});
                } else {
                    layer.msg(res.msg, {time: 1500, icon: 5});
                }
            });
        });
    }
    function showPhoto(url) {
        console.log(url);
        layer.photos({
            photos: {
                "title": "", //相册标题
                "id": 123, //相册id
                "start": 0, //初始显示的图片序号，默认0
                "data": [   //相册包含的图片，数组格式
                    {
                        "alt": "图片",
                        "pid": 1, //图片id
                        "src": url, //原图地址
                        "thumb": "" //缩略图地址
                    }
                ]
            }
            ,anim: 5
        });
    }
</script>
</body>
</html>
